package com.fanfanwang.ffw.app.adapter;

import java.util.ArrayList;

import com.fanfanwang.ffw.app.R;
import com.fanfanwang.ffw.app.bean.CarportBean;
import com.fanfanwang.ffw.app.bean.SectionBean;
import com.fanfanwang.ffw.app.bean.ServiceBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ToggleButton;


public class GlyCarportStatusAdapter extends BaseAdapter {

	private ArrayList<CarportBean> beans;
	private Context mContext;
	public GlyCarportStatusAdapter(Context mContext,ArrayList<CarportBean> beans) {
		// TODO Auto-generated constructor stub
		this.mContext = mContext;
		this.beans = beans;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return beans.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		final ViewHolder holder;
		if (convertView == null) {
			LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.item_for_carport_status, null);
			holder = new ViewHolder();
			holder.carport_num = (TextView) convertView.findViewById(R.id.carport_num);
			holder.tip=(TextView) convertView.findViewById(R.id.carport_tip);
			holder.button=(ToggleButton) convertView.findViewById(R.id.switch_btn);
			final int flag=beans.get(position).isStop;
			
		holder.button.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				// TODO Auto-generated method stub
				if(isChecked)
				{
					holder.tip.setText(mContext.getString(R.string.carport_now_full));
				}else{
					holder.tip.setText(mContext.getString(R.string.carport_now_null));
				}
			}
		});
			convertView.setTag(holder);
		}else {
			holder = (ViewHolder) convertView.getTag();
		}
		return convertView;
	}

	class ViewHolder {
		TextView carport_num;
		TextView tip;//提示按钮的意思
		ToggleButton button;
	}


}
